Skip to content

Linux: Fix FileChooser ignoring the initial directory with zenity#1678

Open
emezeske wants to merge 1 commit into
juce-framework:developfrom
emezeske:pr/linux-filechooser-initial-directory
Open

Linux: Fix FileChooser ignoring the initial directory with zenity#1678
emezeske wants to merge 1 commit into
juce-framework:developfrom
emezeske:pr/linux-filechooser-initial-directory

Conversation

@emezeske

@emezeske emezeske commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

On Linux, a FileChooser constructed with an initial directory opens in $HOME instead of that directory when the zenity backend is used (the default on non-KDE sessions). The kdialog backend is unaffected.

Cause

addZenityArgs() changes the working directory to the target folder and then passes only startingFile.getFileName(), a bare, relative basename, as --filename. zenity/GTK does not resolve a relative --filename, so it is ignored and the dialog falls back to $HOME. When the starting location is a directory, getFileName() returns the directory's own leaf name, which is never what's intended.

Fix

Pass an absolute path in --filename. For a directory, append a trailing separator so zenity opens inside the folder rather than pre-selecting it within its parent. This mirrors what the kdialog branch already does (it passes a full path).

zenity --file-selection --filename=/home/user/Documents/Presets/

Testing

Verified on Wayland with zenity 4.2.1: open, save, and import dialogs now start in the requested directory (presets, environments, recording-output folders) instead of $HOME.

@juce-push-bot

Copy link
Copy Markdown
Collaborator

This pull request has been mentioned on The JUCE Forum. There might be relevant details there:

https://forum.juce.com/t/pr-linux-fix-filechooser-ignoring-the-initial-directory-w-zenity/69088/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants